import { post, get, del, put, patch } from "@/utils/request";
import store from "@/store";
function mergeParams(params) {
    console.log(store, 'mergeParams')
    return {
        ...params,
        username: store.getters.userInfo.username,
        user_id: store.getters.userInfo.user_id,
        username: 'app@gmail.com'
    }
}
export const http = {
    login(data) {
        return post('/identity/auth/token', data)
    },
    logout(username) {
        return post('/clock-out', { username })
    },
    // 获取表情包
    getEmojis() {
        return get('/assets/json/emojis.json')
    },
    // 获取贴纸
    getStickers(data) {
        return post('/operator/media/stickers', mergeParams(data))
    },
    // 获取图片
    getProfileMedia(data) {
      return post('/operator/media/account', mergeParams(data))
    },
    // 获取sent图片
    getProfileSent(data) {
      return post('/operator/media/sent', mergeParams(data))
    },
    sendMarkMedia(data) {
      return post('/operator/media/switch_sent', mergeParams(data))
    },
    getChatList(data) {
        return post('/operator/chat', mergeParams(data))
    },
    getSearchChatList(data) {
        return post('/operator/chat/search', mergeParams(data))
    },
    getChatHistoryList(data) {
        return post('/operator/correspondence/history', mergeParams(data))
    },
    getMailList(data) {
        return post('/operator/mails',mergeParams(data) )
    },
    getMailMessageList(data) {
        return post('/operator/mails/dialog', mergeParams(data))
    },
    // 聊天限制
    getChatLimit(data) {
        return post('/operator/chat/restriction', mergeParams(data))
    },
    // 获取客户信息
    getCustomerInfo(data) {
        return post('/operator/person/customer', mergeParams(data))
    },
    // 获取账号信息
    getProfileInfo(data) {
        return post('/operator/person/profile', mergeParams(data))
    },
    // 获取客户信息媒体资源
    getCustomerOrProfileMedia(data) {
        return post('/operator/media/person/gallery', mergeParams(data))
    },
    // 获取聊天记录
    getChatMessageList(data) {
        return post('/operator/chat/messages', mergeParams(data))
    },
    // 发送消息
    sendChatMessage(data) {
        return post('/operator/chat/send', mergeParams(data))
    },
    // 发送邮件
    sendMail(data) {
        return post('/operator/mails/send', mergeParams(data))
    },
    // 发送贴纸
    sendSticker(data) {
        return post('/operator/media/send/sticker', mergeParams(data))
    },
    // 发送图片
    sendImage(data) {
        return post('/operator/media/send/photos', mergeParams(data))
    },
    // 发送视频
    sendVideo(data) {
        return post('/operator/media/send/photos', mergeParams(data))
    },
    // 获取笔记
    getNoteList(data) {
        return post('/operator/note', mergeParams(data))
    },
    // 添加笔记
    addNote(data) {
        return post('/operator/note', mergeParams(data))
    },
    // 删除笔记
    deleteNote(data) {
        return del('/operator/note', mergeParams(data))
    },
    // 未回复消息
    getUnAnsweredMessage(data) {
        return post('/operator/chat/unanswered', mergeParams(data))
    },
    /**
     * 配置
     */
    getProfileList(data) {
        return post('/identity/profiles', mergeParams(data))
    },
    // 冻结/解冻配置
    freezeProfile({ profileId, status }) {
        return post(`/identity/profiles/${profileId}/${status}`, mergeParams(data))
    },
    // 校验配置
    checkProfile(data) {
        return post('/identity/profiles/verify', mergeParams(data))
    },
    // 保存配置
    addProfile(data) {
        return post('/identity/profiles', mergeParams(data))
    },
    // 删除配置
    deleteProfile(data) {
        return del('/identity/profiles', mergeParams(data))
    },
    // 修改柜子
    updateCabinet(data) {
        return patch('/identity/cabinets', mergeParams(data))
    },
    // 获取站点列表
    getSiteList(data) {
        return post('/platforms', mergeParams(data))
    },
    // 获取平台
    getPlatformList(data) {
        return post('/sub_platforms', mergeParams(data))
    },
    // 修改平台归属
    updatePlatform(data) {
        return patch('/sub_platforms', mergeParams(data))
    },
    // 新增平台
    addPlatform(data) {
        return post('/sub_platforms', mergeParams(data))
    },
    // 删除平台
    deletePlatform(data) {
        return del('/sub_platforms', mergeParams(data))
    },
    // 编辑平台
    editPlatform(data) {
        return put('/sub_platforms', mergeParams(data))
    },
    /**
     * 个人配置中心
     */
    // 获取个人配置
    getPersonalProfile(data) {
        return post('/identity/users/current', mergeParams(data))
    },
    // 修改个人配置
    updatePersonalProfile(data) {
        return put('/identity/users/current', mergeParams(data))
    },
    // 设置语言
    setLanguage(data) {
        return post('/assets', mergeParams(data))
    },
    /**
     * 柜子setting
     */
    // 获取柜子列表
    getCabinetList(data) {
        return post('/identity/cabinets', mergeParams(data))
    },
    // 新建柜子
    addCabinet(data) {
        return post('/identity/cabinets', mergeParams(data))
    },
    // 删除柜子
    deleteCabinet(data) {
        return del('/identity/cabinets', mergeParams(data))
    },
    // 用户更新柜子
    updateUserCabinet(data) {
        return post('/identity/users/cabinets', mergeParams(data))
    },
    // 获取用户
    getUserList(data) {
        return post('/identity/users', mergeParams(data))
    },
    // 新建用户
    addUser(data) {
        return post('/identity/users', mergeParams(data))
    },
    // 删除用户
    deleteUser(data) {
        return del('/identity/users', mergeParams(data))
    },
    // 修改用户
    updateUser(data) {
        return put('/identity/users', mergeParams(data))
    },
    // 获取排期
    getWorkShiftList(data) {
      return post('/identity/shift', mergeParams(data))
    },
    // 用户排班
    updateUserWorkShift(data) {
        return post('/identity/users/shift', mergeParams(data))
    },
    // 新增排班
    addWorkShift(data) {
        return post('/identity/shift', mergeParams(data))
    },
    // 删除排班
    deleteWorkShift(data) {
        return del('/identity/shift', mergeParams(data))
    },
    // 修改排班
    updateWorkShift(data) {
        return patch('/identity/shift', mergeParams(data))
    },
    /**
     * news fead
     */
    // 获取news feed
    getNewsFeed(data) {
        return post('/operator/news-feed', mergeParams(data))
    },
    // 新增
    addNewsFeed(data) {
        return post('/operator/news-feed/create', {
            ...mergeParams(data),
            info: {
                ...mergeParams(data).info,
                user_id: mergeParams(data).user_id
            }
        })
    },
    getNewsFeedStatus(data) {
        return post('/operator/news-feed/statuses', mergeParams(data))
    },
    // 发布
    publishNewsFeed(data) {
        return post('/operator/news-feed', mergeParams(data))
    },
    /**
     * ib页
     */
    // 获取ib列表
    getIBList(data) {
        return post('/scheduler/icebreakers', mergeParams(data))
    },
    getIBNewMessageList(data) {
        return post('/scheduler/icebreakers/approved', mergeParams(data))
    },
    getIBInProgressList(data) {
        return post('/scheduler/icebreakers/in-progress', mergeParams(data))
    },
    // 启用或者禁用
    updateIBStatus(status, data) {
        return post(`/scheduler/icebreakers/auto-sending/${status}`, mergeParams(data))
    },
    // 添加
    addIB(data) {
        return post('/scheduler/icebreakers', mergeParams(data))
    },
    // 发送单条审核
    sendIB(data) {
        return post('/scheduler/icebreakers/send', mergeParams(data))
    },
    trashIb(data) {
      return post('/scheduler/icebreakers/trash', mergeParams(data))  
    },
    /**
     * sender
     */
    // 获取用户的sender数据
    getUserSender(data) {
        return post('/sender/current', mergeParams(data))
    },
    // 获取chat、email的账号任务数据
    getTask(type, data) {
        return post(`/scheduler/tasks/v2/info/task-type/${type}`, mergeParams(data))
    },
    getProfileTask(data) {
        return post('/sender/content',mergeParams(data))
    },
    // 启用或者禁用
    updateProfileSender(status, data) {
        return post(`sender/${status}`, mergeParams(data))
    },
    // 新增
    addProfileSender(data) {
        return post('/sender/tasks/add', mergeParams(data))
    },
    // 删除
    deleteProfileSender(data) {
        return post('/sender/tasks/cancel', mergeParams(data))
    },
    // 任务添加媒体
    addProfileSenderMedia(data) {
        return post('/sender/media', mergeParams(data))
    },
    // 更新条件参数
    updateProfileSenderCondition(data) {
        return post('//sender/current', mergeParams(data))
    },
    /**
     * folder
     */
    // 获取folder列表
    getFolderList(data) {
        return post('/operator/cribs', mergeParams(data))
    },
    // 添加 folder
    addFolder(data) {
        return post('/operator/cribs', {
            ...mergeParams(data),
            info: {
                ...mergeParams(data).info,
                user_id: mergeParams(data).user_id
            }
        })
    },
    // 删除 folder
    deleteFolder(data) {
        return del('/operator/cribs', {
            ...mergeParams(data),
            info: {
                ...mergeParams(data).info,
                user_id: mergeParams(data).user_id
            }
        })
    },
    // 修改 folder
    updateFolder(data) {
        return patch('/operator/cribs', {
            ...mergeParams(data),
            info: {
                ...mergeParams(data).info,
                user_id: mergeParams(data).user_id
            }
        })
    },
    // 获取folder下消息
    getFolderMessage(data) {
        return post('/operator/cribs/messages', mergeParams(data))
    },
    // 添加folder下消息
    addFolderMessage(data) {
        return post('/operator/cribs/messages', mergeParams(data))
    },
    // 删除folder下消息
    deleteFolderMessage(data) {
        return del('/operator/cribs/messages', mergeParams(data))
    },
    // 修改folder下消息
    updateFolderMessage(data) {
        return patch('/operator/cribs/messages', mergeParams(data))
    },
    // 更新状态
    updateFolderMessageStatus(data) {
        return patch('/operator/cribs/messages', mergeParams(data))
    },
    /**
     * 获取用户Balance
     */
    getUserBalance() {
        return post('/user/balance', mergeParams())
    },
    getUserAlert() {
        return post('/user/alert', mergeParams())
    }
}
